package com.greenlife.controller.util;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

import org.springframework.stereotype.Component;

@Component("timeHelper")
public class TimeHelper {

	public static int transformpresenttime() {
		long time = System.currentTimeMillis() / 1000;
		return (int) time;
	}

	public static Integer transformtimetamp(String TimeParam) {
		if(TimeParam==null||TimeParam.equals("")){
			return null;
		}
		SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		Date date;
		long time = 0000000000;
		try {
			date = dateFormat.parse(TimeParam);
			time = date.getTime() / 1000;
		} catch (ParseException e) {
			e.printStackTrace();
		}
		return (int)time;
	}

}
